﻿using System;
using System.Linq.Expressions;
using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Project;
using Autofac.Extras.DynamicProxy;
using MongoDB.Driver;
using Rhonin.Common.Components;
using Rhonin.Common.UnitOfWork.Transaction;

namespace ApiManage.Applications.Mongo.Project.Impl
{
    [Component]
    [Intercept(typeof(TransactionInterceptor))]
    public class ProjectService : IProjectService
    {
        private readonly IProjectRepository<Projects> _projectRepository;
        public ProjectService(IProjectRepository<Projects> projectRepository)
        {
            _projectRepository = projectRepository;
        }


        public void Insert(Projects param)
        {
            _projectRepository.InsertOne(param);
        }

        public void Update(Expression<Func<Projects, bool>> fitter, UpdateDefinition<Projects> updateDefinition)
        {
            _projectRepository.Update(fitter, updateDefinition);
        }
        public void Delete(Expression<Func<Projects, bool>> fitter)
        {
            _projectRepository.Delete(fitter);
        }
    }
}
